home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / menu / kiwi / demoprg / fenster.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-29  |  4.7 KB  |  240 lines

  1. #include<stdlib.h>
  2. #include<kiwi_inc.h>
  3. #include<kiwipro.h>
  4. #include<demopro.h>
  5.  
  6. #define MAX_STAPEL 15
  7. static WINDOW win[MAX_STAPEL],w;
  8.  
  9. int zeige_dyn_fenster()
  10. {
  11. int i;
  12. unsigned mx,my;
  13. VSCREEN vs[3];
  14.  
  15. set_color_table(1);
  16. win[0]=load_window("DEMO1.WND");
  17. vs[0]=get_linked_screen(win[0]);
  18.  
  19. set_color_table(2);
  20. win[1]=load_window("DEMO20.WND");
  21. vs[1]=get_linked_screen(win[1]);
  22.  
  23. set_color_table(3);
  24. win[2]=load_window("DEMO21.WND");
  25. vs[2]=get_linked_screen(win[2]);
  26.  
  27. for(i=3;i<6;i++)
  28. {
  29.     win[i]=open_window("",5+5*i,4*i,22+5*i,4+4*i,DOPPELT);
  30.     link_virtuell_screen(vs[i-3],win[i],i*5,i*5);
  31. }    
  32.  
  33. do
  34. {
  35.     mouse(&mx,&my);
  36. }while(input()!=27);
  37.  
  38. for(i=5;i>=0;i--)close_window(win[i]);
  39. return(0);
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. /*****************************************************************************
  48. *Name :zeige_stapel_window
  49. *Typ  :int
  50. *Zweck:Zeigt die funktion Stapeln
  51. *
  52. *
  53. *        Name    Typ    Zweck
  54. *Aufrufpara :
  55. *
  56. *Rueckgabep :
  57. *
  58. *Funktionswt:        0    Immer
  59. *
  60. *****************************************************************************/
  61. int zeige_stapeln_window()
  62. {
  63. int i,wide,height,color,count;
  64. int xa,ya,xe,ye,ptr,num,maxx,maxy;
  65. UINT mx,my;
  66. unsigned char c;
  67.  
  68. w=load_window("demo14.wnd");
  69. wait_of_action();
  70.  
  71. wide=get_screen_wide();        /* Hole Bildschirmgroesse    */
  72. height=get_screen_height();
  73. color=ptr=0;
  74. maxx=(int)(32768l/wide);
  75. maxy=(int)(32768l/height);
  76. count=0;
  77. while(!input() && mouse(&mx,&my) !=2)            /* Solange keine Taste gedrueckt    */
  78. {
  79.     num=rand();        
  80.     xa=num/maxx;
  81.     num=rand();        
  82.     xe=num/maxx;
  83.     if(xa>xe)swap_int(&xa,&xe);
  84.     if(xe-xa<8)xe=xa+8;
  85.  
  86.     num=rand();        
  87.     ya=num/maxy;
  88.     num=rand();        
  89.     ye=num/maxy;
  90.     if(ya>ye)swap_int(&ya,&ye);
  91.     if(ye-ya<5)ye=ya+5;
  92.                     /* erzeuge Fenstergroesse    */
  93.     if(count==0){            /* Setze Farbe, Form, Rand    */
  94.         c=EINFACH;
  95.         FLIPC
  96.         count++;}
  97.     else if(count==1){
  98.         FLIPC
  99.         c=DOPPELT;
  100.         count++;}
  101.     else {
  102.         if(++color>4)color=0;
  103.         set_color_table(color);
  104.         c=KEIN_RAND;
  105.         count=0;}
  106.  
  107.     /* Ist Stapel noch nicht voll dann lege Fenster drauf    */
  108.     if(ptr<MAX_STAPEL)win[ptr++]=open_window("Stapeltest",xa,ya,xe,ye,c);
  109.     else {    /* Stapel ist Voll, loesche erste das unterste    */
  110.         close_window(win[0]);
  111.         for(i=0;i<MAX_STAPEL-1;i++)win[i]=win[i+1];/* Jetzt oben daruf    */
  112.         win[MAX_STAPEL-1]=open_window("Stapeltest",xa,ya,xe,ye,c);
  113.         }
  114.  
  115. };
  116. for(i=0;i<ptr;i++)close_window(win[i]);
  117. close_window(w);
  118.  
  119. return(0);
  120. }
  121.  
  122.  
  123. /*****************************************************************************
  124. *Name :zeige_fenster_farbe
  125. *Typ  :int
  126. *Zweck:Zeigt die Funktion Einfaerben
  127. *
  128. *
  129. *        Name    Typ    Zweck
  130. *Aufrufpara :
  131. *
  132. *Rueckgabep :
  133. *
  134. *Funktionswt:        0    Immer
  135. *
  136. *****************************************************************************/
  137. int zeige_fenster_farbe()
  138. {
  139. int color=0,count;
  140. UINT mx,my;
  141.  
  142. w=load_window("demo14.wnd");
  143. wait_of_action();
  144.  
  145. count=0;
  146. while(!input() && mouse(&mx,&my)!=2)    /* Solange keine Taste gedrueckt    */
  147. {
  148.     if(count==0){    /* Waehle Farbe aus Tabellen    */
  149.         FLIPC
  150.         count++;}
  151.     else if(count==1){
  152.         FLIPC
  153.         count++;}
  154.     else {
  155.         if(++color>4)color=0;
  156.         set_color_table(color);
  157.         count=0;}
  158.  
  159.     set_window_attribut(w,ATTRIBUT);    /* Setze Neue Farbe    */
  160.     kw_wait(20);                /* Warte 20 Hunderstel    */
  161. };
  162.  
  163. close_window(w);
  164.  
  165. return(0);
  166. }
  167.  
  168.  
  169.  
  170.  
  171.  
  172. /*****************************************************************************
  173. *Name :zeige_schreiben_window
  174. *Typ  :int
  175. *Zweck:Zeigt Fensterbeschreiben
  176. *
  177. *
  178. *        Name    Typ    Zweck
  179. *Aufrufpara :
  180. *
  181. *Rueckgabep :
  182. *
  183. *Funktionswt:        0    Immer
  184. *
  185. *****************************************************************************/
  186. int zeige_schreiben_window()
  187. {
  188. int i,j,wide,height,color=0,count=0;
  189. int xa,ya,xe,ye,ptr;
  190. UINT mx,my;
  191. unsigned char c;
  192.  
  193. w=load_window("demo14.wnd");
  194. wait_of_action();
  195.  
  196. wide=get_screen_wide();
  197. height=get_screen_height();
  198. color=ptr=0;
  199. ptr=(wide/6 < height/4) ? wide/6 : height/4;
  200. if(ptr>MAX_STAPEL)ptr=MAX_STAPEL-1;
  201.  
  202. while(!input() && mouse(&mx,&my)!=2)
  203. {
  204.     for(i=0;i<ptr;i++)    /* Erzeuge nacheinander Fenster    */
  205.     {
  206.         if(count==0){
  207.             c=EINFACH;
  208.             FLIPC
  209.             count++;}
  210.             else if(count==1){
  211.             FLIPC
  212.             c=DOPPELT;
  213.             count++;}
  214.         else {
  215.             if(++color>4)color=0;
  216.             set_color_table(color);
  217.             c=KEIN_RAND;
  218.             count=0;}
  219.     
  220.         xa=1+i*3;
  221.         xe=wide-i*3;
  222.         ya=1+i*2;
  223.         ye=height-i*2;
  224.     
  225.         win[i]=open_window("Schreibtest",xa,ya,xe,ye,c);
  226.     }
  227.     for(j=1;j<height+2;j++)/* Schreibe in jedes Fenster an jede Stelle    */
  228.     for(i=0;i<ptr;i++)
  229.     display_string("Das ist ein Test bei dem in ein verdecktes Fenster in der Fensterfarbe geschrieben wird",win[i],AL,j); 
  230.     kw_wait(150);
  231.     
  232.     if(count)for(i=ptr-1;i>=0;i--)close_window(win[i]);
  233.     else     for(i=0;i<ptr;i++)close_window(win[i]);
  234.     
  235. };
  236.  
  237. close_window(w);
  238. return(0);
  239. }
  240.